#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
int main(){
    ifstream f;
    int m[5000], c, s = 0;
    f.open("m1_sorted.txt");
    for (int i = 0; i < 5000; i++){
        f >> m[i];
    }
    f.close();
    unsigned int st = clock();
    for (int j = 0; j < 4998; j++){
        for (int i = 4998; i >= 0; i--){
            if (m[i] > m[i + 1]){
                c = m[i];
                m[i] = m[i + 1];
                m[i + 1] = c;
                s = 1;
            }
        }
        if (s == 0){
            break;
        }
    }
    unsigned int fi = clock();
    cout << "m1_sorted " << (fi - st) << " milliseconds\n";
    f.open("m2_reverse.txt");
    for (int i = 0; i < 5000; i++){
        f >> m[i];
    }
    f.close();
    st = clock();
    for (int j = 0; j < 4998; j++){
        for (int i = 4998; i >= 0; i--){
            if (m[i] > m[i + 1]){
                c = m[i];
                m[i] = m[i + 1];
                m[i + 1] = c;
                s = 1;
            }
        }
        if (s == 0){
            break;
        }
    }
    fi = clock();
    cout << "m2_reverse " << (fi - st) << " milliseconds\n";
    f.open("m3_shuffle.txt");
    for (int i = 0; i < 5000; i++){
        f >> m[i];
    }
    f.close();
    st = clock();
    for (int j = 0; j < 4998; j++){
        for (int i = 4998; i >= 0; i--){
            if (m[i] > m[i + 1]){
                c = m[i];
                m[i] = m[i + 1];
                m[i + 1] = c;
                s = 1;
            }
        }
        if (s == 0){
            break;
        }
    }
    fi = clock();
    cout << "m3_shuffle " << (fi - st) << " milliseconds";
}
